<form action="" id="myform">
<div id="inline1">
<h2><span>销售机会信息</span></h2>
<table>
    <tr><th colspan="7">机会：</th></tr>
    <tr>
        <td class="name" width="80">机会主题：</td>
        <td>&nbsp;</td>
        <td colspan="5" id="customer_name"><input type="hidden" id="show_text" value="<?=$find_sales->subject?>"/> <span><?=$find_sales->subject?></span></td>
    </tr>
    <tr>
        <td class="name" width="80" >客户：</td>
        <td>&nbsp;</td>
        <td colspan="5"><?=$find_sales->customer_name?></td>
    </tr>
    <tr>
        <td class="name" width="80">客户联系人：</td>
        <td>&nbsp;</td>
        <td colspan="5"><?=$find_sales->name?></td>
    </tr>
    <tr>
        <td class="name" width="80">状态：</td>
        <td>&nbsp;</td>
        <td width="170" colspan="5"><?=$find_sales->status?></td>
    </tr>
    <tr><th colspan="7">基本情况：</th></tr>
    <tr>
        <td class="name" width="80">发现时间：</td>
        <td>&nbsp;</td>
        <?php 
            $findtime = '';
         if($find_sales->find_time != '0000-00-00 00:00:00'){
         	$findtime = substr ( $find_sales->find_time, 0, 10 );
         }
        ?>
        <td width="170"><?= $findtime?></td>
        <td>&nbsp;</td>
        <td class="name" width="80">来源：</td>
        <td>&nbsp;</td>
        <td width="170"><?=$find_sales->source?></td>
    </tr>
    <tr>
        <td class="name" width="80">负责人：</td>
        <td>&nbsp;</td>
        <td width="170"><?=$find_sales->principal?></td>
        <td>&nbsp;</td>
        <td class="name" width="80">提供人：</td>
        <td>&nbsp;</td>
        <td width="170"><?=$find_sales->provider?></td>
    </tr>
    <tr>
        <td class="gj_name" width="80">客户需求：</td>
        <td>&nbsp;</td>
        <td height="80" colspan="5" valign="top"><?=$find_sales->customer_demand?></td>
    </tr>
    <tr><th colspan="7">预期：</th></tr>
    <tr>
        <td class="name" width="80">预计签单日期：</td>
        <td>&nbsp;</td>
        <?php
        $expectedsigningdate = '';
         if($find_sales->expected_signing_date != '0000-00-00 00:00:00'){
         	$expectedsigningdate = substr ( $find_sales->expected_signing_date, 0, 10 );
         }
        ?>
        <td width="170"><?= $expectedsigningdate;?></td>
        <td>&nbsp;</td>
        <td class="name">预期金额：</td>
        <td>&nbsp;</td>
        <?php 
        $expected_amount = '';
        $unit = '';
         if($find_sales->expected_amount){
         	$expected_amount = $find_sales->expected_amount;
         	$unit = '万元';
         }
        ?>
        <td width="170"><?= $expected_amount?><?php echo $unit;?></td>
    </tr>
    <tr><th colspan="7">当前状态：</th></tr>
    <tr>
        <td class="name" width="80">阶段：</td>
        <td>&nbsp;</td>
        <td width="170"><?=$find_sales->stage?></td>
        <td>&nbsp;</td>
        <td class="name" width="80">可能性：</td>
        <td>&nbsp;</td>
        <td width="170"><?=$find_sales->possibility?>%</td>
    </tr>
    
    <tr>
        <td class="gj_name" width="80">阶段备注：</td>
        <td>&nbsp;</td>
        <td height="80" colspan="5" valign="top"><?=$find_sales->stage_remark?></td>
    </tr>
    <tr><th colspan="5">机会阶段推进历史：</th></tr>
    <?php $i=0;$last_time;$t=1;$time1_count=count($time1);?>
    <?php foreach($opportunity_stages as $opportunity_stage):?>
        <tr>
        	<?php $time = substr ( $opportunity_stage['update_time'], 0, 10 );?>
			 <?php 
			 $possibility="";
			 if($opportunity_stage['possibility']){
			 	$p = $opportunity_stage['possibility'];
			 	$possibility="("."$p"."%)";
			 }
			 ?>      	
            <td colspan="7">
	            <span class="span_right">日期：<?= $time?></span>
	            <span class="span_right">状态：<?= $opportunity_stage['stage']?><?= $possibility?></span>
	            <span class="span_right">用户：<?= $opportunity_stage['user_name']?></span>
            </td>
        </tr>
        <?php if($t!=$time1_count):?>
            <?php 
	            $next_date=strtotime($time1[$t]);
	            $last_date=strtotime($opportunity_stage['update_time']);
	            $interval_time = ($next_date-$last_date)/3600;
	            $unit = '小时';$int_hour='';$hour = '';
	            if($interval_time < 1){
	            	$interval_time = ($next_date-$last_date)/60;
	            	$unit = '分钟';
	            }
	            if($interval_time >= 24){
	            	$intval_time = intval($interval_time);
	            	$days = $intval_time/24;
	            	$decimals = explode(".", $days);

	            	$minute = doubleval('0.'.$decimals[1]);
	            	$int_hour=round($minute,3)*24;
	            	$interval_time = intval($days);
	            	$unit = '天';
	            	$hour = '小时';
	            }
            ?>
        	<tr>
            	<td valign="top" colspan="5">阶段停留：
            	<?php echo round($interval_time,2);?><?php echo $unit;?>
            	<?php echo $int_hour;?><?php echo $hour;?>
            	</td>
        	</tr>
        <?php endif;?>
        <tr>
            <td colspan="7">阶段备注：<?= $opportunity_stage['remark']?></td>
        </tr>
		<tr><td style=" height:10px; line-height:10px;">&nbsp;</td></tr>
		<?php $i++; $last_time=$opportunity_stage['update_time']; $t++;?>
        <?php endforeach;?>
    <tr><td colspan="5">&nbsp;</td></tr>
    <!-- <tr class="sub">
            <td colspan="5"><input type="button" id="console_check_opp" value="编辑" /></td>
        </tr> -->
</table>
</div>
</form>

<script type="text/javascript">
	$(function(){
		$("#console_check_opp").click(function(){
			alert('1');
		})
	})
</script>

